package com.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.model.RequestMessage;
import com.model.TestModel;
import com.producer.MqProducer;

@Controller
public class MqController 
{
	@Autowired
	private MqProducer producer;
	
	@RequestMapping("/send")
	@ResponseBody
	public String sendMsg() 
	{
		RequestMessage<TestModel> message = new RequestMessage<>();
		message.setRequestID(UUID.randomUUID().toString());
		message.setServiceName("MQ_TEST");
		message.setSourceSystem("ABC");
		message.setTargetSystem("CBA");
		TestModel testModel =new TestModel();
		List<TestModel> modelList = new ArrayList<>();
	    testModel.setName("fxx");
	    testModel.setAge(18);
	    testModel.setGender("girl");
	    modelList.add(testModel);
	    message.setData(modelList);
		producer.sendNotification(message);
		return "success";
	}
}
